package com.atguigu.inner.anymous;

public class TestCircle {
    public static void main(String[] args) {
        Circle[] circles = new Circle[3];
        circles[0] = new Circle(2.0);
        circles[1] = new Circle(1.5);
        circles[2] = new Circle(1.0);

        MyComparator my = new MyComparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Circle c1 = (Circle) o1;
                Circle c2 = (Circle) o2;
//                return (int) (c1.getRadius() - c2.getRadius());//有瑕疵
                if(c1.getRadius() > c2.getRadius()){
                    return 1;
                }else if(c1.getRadius() < c2.getRadius()){
                    return -1;
                }else{
                    return 0;
                }
            }
        };
        Object max = MyArrays.findMax(circles, my);
        System.out.println("半径最大的圆：" + max);
    }
}
